﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using KeMei.Common;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            try
            {
                FlashBind();
                ProductExhibitionBind();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
            finally
            {

            }
        }
    }


    /// <summary>
    /// 取得资料地址
    /// </summary>
    /// <param name="source"></param>
    /// <returns></returns>
    protected string GetFileUrl(string source)
    {
        if (string.IsNullOrEmpty(source))
        {
            return ConfigHelper.SystemUrl + "Style/img/noimages.jpg";
        }
        return ConfigHelper.SystemUrl + source;
    }

    /// <summary>
    /// 产品展示
    /// </summary>
    private void ProductExhibitionBind()
    {
        KeMei.BLL.ProductAndCase bll = new KeMei.BLL.ProductAndCase();
        DataSet ds = bll.GetTopDataByIsShow(15, " (IsHomePageShow = True)  order by Taxis desc");

        DataTable dt = ds.Tables[0];
        if (dt.Rows.Count > 0)
        {
            repProductExhibition.DataSource = dt;
            repProductExhibition.DataBind();
        }
    }

    /// <summary>
    /// 首页Flash图片显示
    /// yd 2012-05-17
    /// </summary>
    private void FlashBind()
    {
        KeMei.BLL.FlashScreen bll = new KeMei.BLL.FlashScreen();

        DataSet ds = bll.GetTopDataByIsShow(5, " (IsShow =True) order by Taxis desc");
        DataTable dt = ds.Tables[0];
        if (dt.Rows.Count > 0)
        {
            string str = string.Empty;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //选中第一张图片
                if (i == 0)
                {
                    str += "<a class=\"trigger imgSelected\" href=\"javascript:void(0)\">" + (i + 1) + "</a>";
                }
                else
                {
                    str += "<a class=\"trigger\" href=\"javascript:void(0)\">" + (i + 1) + "</a>";
                }
            }
            spanTab.InnerHtml = str;

            repFalsh.DataSource = dt;
            repFalsh.DataBind();
        }
        else
        {
            jsNav.Style["display"] = "none";
        }
    }
}